package com.salestax.core;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Product {

	private BigDecimal basePrice;
	private String description;
	private int quantity;
	protected List<Tax> taxes = new ArrayList<Tax>();

	public Product(String description,double basePrice,int quantity) {
		this.basePrice = new BigDecimal(basePrice);
		this.description = description;
		this.quantity = quantity;
	}

	public Product addTax(Tax tax) {
		taxes.add(tax);
		return this;
	}

	public BigDecimal getBasePrice() {
		return basePrice;
	}

	public BigDecimal getContributingTax() {
		BigDecimal total = new BigDecimal(0);
		for (Tax tax : taxes) {
			total = total.add(tax.calculateTax(this));
		}
		return total.multiply(new BigDecimal(quantity));
	}

	public BigDecimal getTotalPrice() {
		return basePrice.add(getContributingTax()).multiply(new BigDecimal(quantity));
	}

	public List<Tax> getTaxes() {
		return taxes;
	}
	
	public String getDescription(){
		return description;
	}
	
	public int getQuantity(){
		return quantity;
	}
		

}
